import 'package:flutter/material.dart';
import 'package:asr_onnx_ffi/main.dart' as app;

/// 简单的测试程序来验证音频文件选择功能
void main() {
  runApp(const TestApp());
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ASR 音频文件选择测试',
      theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: true),
      home: const TestHomePage(),
    );
  }
}

class TestHomePage extends StatelessWidget {
  const TestHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ASR 音频文件选择测试'),
        backgroundColor: Colors.blue.shade100,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text(
              '测试音频文件选择功能',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 20),
            const Text('点击下面的按钮启动完整的ASR应用', style: TextStyle(fontSize: 16)),
            const SizedBox(height: 30),
            ElevatedButton.icon(
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) =>
                        app.ASRHomePage(title: 'ASR ONNX 离线测试'),
                  ),
                );
              },
              icon: const Icon(Icons.play_arrow),
              label: const Text('启动 ASR 应用'),
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.blue.shade100,
                padding: const EdgeInsets.symmetric(
                  horizontal: 30,
                  vertical: 15,
                ),
              ),
            ),
            const SizedBox(height: 20),
            const Card(
              margin: EdgeInsets.all(20),
              child: Padding(
                padding: EdgeInsets.all(16),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '功能说明:',
                      style: TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    SizedBox(height: 10),
                    Text('• 支持选择自定义音频文件进行识别'),
                    Text('• 支持的格式: WAV, MP3, FLAC, M4A, AAC, OGG'),
                    Text('• 提供离线和在线两种识别模式'),
                    Text('• 自动验证文件格式和大小'),
                    Text('• 预设示例音频文件快速测试'),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
